package com.sz.myinterface;

import com.aliyun.api.gateway.demo.util.HttpUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

public class MyBankCard {

    //传入银行卡号
    public static String getBankCard(String card){

        String host = "https://dfbankvr.market.alicloudapi.com";
        String path = "/verify_bankcard";
        String method = "POST";
        String appcode = "045ca0303c534d55bec9100912040eb5";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        //根据API的要求，定义相对应的Content-Type
        headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
        Map<String, String> querys = new HashMap<String, String>();
        Map<String, String> bodys = new HashMap<String, String>();
        bodys.put("card_number", card);

        String str="";
        try {
            HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
            System.out.println(response.toString());

            str=EntityUtils.toString(response.getEntity());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return str;
    }

    public static void main(String[] args) {

        //System.out.println(getBankCard("6217003320069096546"));
    }
}
